/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package WSModel;

import weka.core.Attribute;
import weka.core.FastVector;
import weka.core.Instances;
import weka.core.Instance;

/**
 *
 * @author acer
 */
public class Attribute_Builder {

    private Attribute attr;

    public Attribute getAttr() {
        return attr;
    }

    public Attribute_Builder(String attrname,String val)
    {
        String name = attrname;
        String pattern = ",";
        String splitter1 = val.replaceAll("[\\{\\}]", "");
        String[] splitter = splitter1.split(pattern);
        FastVector attrVal = new FastVector();
        int i=0;
        while(i<splitter.length)
        {
            attrVal.addElement(splitter[i]);
            i++;
        }
        this.attr = new Attribute(attrname,attrVal);
    }

    public static void main(String args[])
    {
//    {
//        Attribute_Builder ab =new Attribute_Builder("attr1","{true,false}");
//        Attribute attr = ab.getAttr();
//        System.out.println(attr.name());
//
//        String test = "@attribute art {true,false}";
//        String [] test1 = test.split(" ");
//        System.out.println(test1[0]);
//            Attribute length = new Attribute("length");
//    Attribute weight = new Attribute("weight");
//
//    FastVector my_nominal_values = new FastVector(3);
//    my_nominal_values.addElement("first");
//    my_nominal_values.addElement("second");
//    my_nominal_values.addElement("third");
//
//    Attribute position = new Attribute("position",my_nominal_values);
//
//    FastVector atts = new FastVector();
//    atts.addElement(length);
//    atts.addElement(weight);
//    atts.addElement(position);
//    Instances race = new Instances("race", atts, 0);
//
//    Instance inst = new Instance(race.numAttributes());
//
//    inst.setValue(length, 5.3);
//    inst.setValue(weight, 300);
//    inst.setValue(position, "first");
//
//    // Set instance’s dataset to be the dataset ‘‘race’’
//    inst.setDataset(race);
//
//    System.out.println("The instance: " + inst.dataset());
//
//        race.add(inst);
//        System.out.println("The instances: " + race);
        String_Reader sr = new String_Reader("helloworld\nhello\ni\nyeah");
        while(sr.hasNextLine())
         System.out.println(sr.readLine());

        String test = "TESt,t,t,te,s,df";
        String pattern ="^(\\w+)((,?)(\\w+))*"; //"^(@relation) (\\S+) (\\{\\S+,\\S+\\})";
        System.out.println(test.matches(pattern));
       

    }
}
